home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SCREEN.SWG / 0010_SCRNSAVE.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  99 lines

  1. { GLEN WILSON }
  2.  
  3. {$m 2000,0,0}  (* Stops Pascal using all of memory *)
  4. {$R-,s-,v-,b-,n-,l+}  (* Nothing important, helps keep the size down*)
  5. Program screensaver;  (* Only blanks screen on CGA/Mono not VGA/etc*)
  6.  
  7. Uses
  8.   Dos, Crt;
  9.  
  10. Const
  11.   TimerInt = $08;              {Timer Interrupt}
  12.   KbdInt   = $09;              {Keyboard Interrupt}
  13.   Timerlimit : Word = 5460;   {5 minute Delay}
  14.  
  15. Var
  16.   Regs    : Registers;
  17.   Cnt     : Word;
  18.   PortNum : Word;
  19.   PortOff : Word;
  20.   Porton  : Word;
  21.   OldKBDVEC   : Pointer;
  22.   OldTimerVec : Pointer;
  23.   i    : Real;
  24.   code : Real;
  25.  
  26.  
  27. Procedure STI;
  28. Inline($FB);
  29.  
  30. Procedure CLI;
  31. Inline($FA);
  32.  
  33. Procedure CallOldInt(Sub : Pointer);
  34. (* Primitive way of calling Old Interrupt, never the less, you can see what is
  35.    happening! *)
  36. begin
  37. Inline($9c/           { PushF }
  38.        $FF/$5e/$06);  { Call DWord PTR [BP+6] }
  39. end;
  40.  
  41. Procedure Keyboard(flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP : Word); Interrupt;
  42.  
  43. begin
  44.   CallOldInt(OldKbdVec);
  45.   if (CNT >= Timerlimit) then
  46.     port[portnum] := porton;
  47.   Cnt := 0;
  48.   STI;
  49. end;
  50.  
  51. Procedure Clock(flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP : Word); Interrupt;
  52. begin
  53.   CallOldInt(OldTimerVec);
  54.   if (CNT > Timerlimit) then
  55.     Port[portnum] := portoff
  56.   else
  57.     Inc(Cnt);
  58.   STI;
  59. end;
  60.  
  61.  
  62. begin
  63.  Regs.AH := $0F;
  64.  INTR($10, regs); (* determine Type of video adapter (Mono or Cga) *)
  65.  
  66.   if Regs.AL= 7 then
  67.   begin
  68.     Portnum := $3b8;
  69.     Portoff := $21;
  70.     PortOn  := $2d;
  71.   end
  72.   else
  73.   begin
  74.     Portnum:=$3d8;
  75.     Portoff:=$25;
  76.     porton :=$2d;
  77.   end;
  78.  
  79.   (* Save original Procedures *)
  80.   GetIntVec(KbdInt, OldKbdVEc);
  81.   GetIntVec(TimerInt, OldTimerVec);
  82.  
  83.   (* Install new Interrupts *)
  84.   SetIntVec(timerint, @clock);
  85.   SetIntVec(KbdInt, @Keyboard);
  86.  
  87.   Cnt := 0; (* Initialize counter *)
  88.   Keep(0); (* Tell Pascal to keep us in memory *)
  89. end.
  90.  
  91. {
  92. it seems rather complex but most of that crap is For turning
  93. on and off the screen.  if you don't have a CGA or MONO you can replace the
  94. Port crap With Writeln statements so you can see whats hapening.
  95.  
  96. BTW This is an example from a Programming book ( can't remember what it is
  97. called ) becareful, It might be covered by Copy right laws.
  98. }
  99.